﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;

using ibba.src.norisk.BusinessLogic;
using ibba.src.norisk.Contracts;


/*****************************************************************************************************************          
 Copyright © 2010 - Banco Itaú BBA S.A          
          
 Instrumento  : 
            
 Histórico de Alterações:      
12/08/2010 - AAALVES	- Criacao OS393398

 *****************************************************************************************************************/

namespace ibba.src.norisk.ServiceImplementation
{

    [AspNetCompatibilityRequirements(RequirementsMode = System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,
                     ConcurrencyMode = ConcurrencyMode.Multiple)]

    class Instrumento : IInstrumento 
    {

        private InstrumentoBL _instrumentoBL;

        public Instrumento()
        {

            try
            {
                _instrumentoBL = new InstrumentoBL();
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

        }

        public List<ibba.src.norisk.Contracts.Instrumento> ObterInstrumento()
        {
            List<ibba.src.norisk.Contracts.Instrumento> retorno = null;

            try
            {

                retorno = TranslateInstrumento.Translate(_instrumentoBL.ObterInstrumento());
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return (retorno);
        }

        public int AtualizarInstrumento( List<Contracts.Instrumento> pInstrumento, string pCodUsuario)
        {
            int retorno = 0;

            try
            {

                retorno = _instrumentoBL.AtualizarInstrumento(TranslateInstrumento.Translate(pInstrumento), pCodUsuario);
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return (retorno);
        }

    }
}
